{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X, y = datasets.make_moons()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 2)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD8CAYAAACfF6SlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAHfpJREFUeJzt3X+wZGWd3/H3h5k7cHV1LsiocGdm\nBzejLgKK3EJdUgnKDweqYAi6CMYIG9kps0VMNglxKC202LJmXJKwS0ncJcYV3MgPlcC4YHBlIJtY\ngTAsv8GBcVaWO0PJLDCTEEbnB9/80X2hp+85fbtvnz4/P6+qqds/nunznD7P8+3Tz/M9TysiMDOz\nZjmo6AqYmVn+HPzNzBrIwd/MrIEc/M3MGsjB38ysgRz8zcwayMHfzKyBHPzNzBrIwd/MrIEWFl2B\nNIcffnisWLGi6GqYmVXKAw888HcRsWSucqUN/itWrGDTpk1FV8PMrFIkPdNPOQ/7mJk1kIO/mVkD\nOfibmTWQg7+ZWQM5+JuZNZCDv5lZA2US/CV9U9Lzk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pK0iJaE46lyZRp2wBc2L59ITDrG42kQyUd\n3L59OHAS8ERuNUzXz/vbuX8fBzZGe5arRObcj64x2LNpjd1W0Qbg0+0Mkw8Cu2aGHatE0ttn5o4k\nnUgrvr3Q+3/lr13H/ww8GRH/IaXY6I9J0TPfGc+i/yNan5i/An4B3Nl+/Ejgjq6Z9KdonSV/oeh6\nJ+zHW4C7gKfbfw9rPz4FfKN9+7eAR2lloTwKfKboevd6f4ErgLPbtw8BvgtsAf438I6i6zzP/VgH\nPN4+BncD7y66zin7cQPwHLC33T8+A3wW+Gz7eQHXtPfzUVIy5Yr+18d+XNJxPO4FfqvoOqfsx9+n\nNYTzCPBQ+9+ZeR8TX+FrZtZATRz2MTNrPAd/M7MGcvA3M2sgB38zswZy8DczayAHfzOzBnLwNzNr\nIAd/M7MG+v83YLt1bjiUiwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1082fe940>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[y == 0, 0], X[y == 0, 1])\n",
    "plt.scatter(X[y == 1, 0], X[y == 1, 1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X, y = datasets.make_moons(noise=0.15, random_state=666)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3X/QZFV95/H3h2GAyerO8EuFmXkE\nalkUBcE8i0ZSq/xGU2FYNQTcrGMV1BQVXXe1Qj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woHBzMxaODCYmVkLBwYzM2vhwGBmZi3+P0fgkUloMjyPAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x108a39080>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[y == 0, 0], X[y == 0, 1])\n",
    "plt.scatter(X[y == 1, 0], X[y == 1, 1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 使用多项式特征的SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures, StandardScaler\n",
    "from sklearn.svm import LinearSVC\n",
    "from sklearn.pipeline import Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def PolynomialSVC(degree, C = 1.0):\n",
    "    return Pipeline(\n",
    "        [\n",
    "            (\"poly\", PolynomialFeatures(degree=degree)),\n",
    "            (\"std_scaler\", StandardScaler()),\n",
    "            (\"linearSVC\", LinearSVC(C = C))\n",
    "        ]\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "poly_svc = PolynomialSVC(degree=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Pipeline(memory=None,\n",
       "     steps=[('poly', PolynomialFeatures(degree=3, include_bias=True, interaction_only=False)), ('std_scaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('linearSVC', LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True,\n",
       "     intercept_scaling=1, loss='squared_hinge', max_iter=1000,\n",
       "     multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,\n",
       "     verbose=0))])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly_svc.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def plot_decision_boundary(model, axis):\n",
    "    \n",
    "    x0, x1 = np.meshgrid(\n",
    "        np.linspace(axis[0], axis[1], int((axis[1] - axis[0]) * 100)).reshape(-1, 1),\n",
    "        np.linspace(axis[2], axis[3], int((axis[3] - axis[2]) * 100)).reshape(-1, 1)\n",
    "    )\n",
    "    X_new = np.c_[x0.ravel(), x1.ravel()]\n",
    "    \n",
    "    y_predict = model.predict(X_new)\n",
    "    zz = y_predict.reshape(x0.shape)\n",
    "    \n",
    "    from matplotlib.colors import ListedColormap\n",
    "    custom_cmap = ListedColormap(['#EF9A9A', '#FFF59D', '#90CAF9'])\n",
    "    \n",
    "    plt.contourf(x0, x1, zz, linewidth=5, cmap=custom_cmap)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/Winter/anaconda3/lib/python3.6/site-packages/matplotlib/contour.py:967: UserWarning: The following kwargs were not used by contour: 'linewidth'\n",
      "  s)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3X+QHOWd3/H3V6s9tMYrFhl0yBJG\nxgZiMIlkKM4+pRKKwxdLToEvJ+ewpTqZsqNycoBcVKrMRVdciioq5lJFlcC+ODqfOTm4/CNK4uNi\nqThk7DilBMf8tFg4yYIyZq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5nv3IOcj0r1WVkZmea2Xj7MfC7tPZkCE0Iy3U8AGyKHm8C3tSyMbOzzeyM6PE5\nwBqKWZY8zfXpLP964GEXjZQVqG85u/qOr6PVlxuaB4A/jLJj3g8cbXcnhsTMzmuPE5nZVbTuT6/0\n/invZTDgL4FnnXN3JxxW+vV+JbnHAAAA4klEQVRMU86BrmfRo+M9Rs1/j1bk/TXwc+DB6Pm3A7ui\nxxfSyvR4Cpik1YUTXDndG5kIB2jVtsso59uA7wA/jv5dEj1/JfCl6PFvA/ui67kP+GSB5XvT9QHu\nAK6LHi8C/itwEPh/wIUlvS/7lfM/RO/Fp4DvAv+ghDJ+DZgGTkTvzU8CnwY+Hb1utDapei76Oydm\n8ZVczps6ruUjwG+XUMZ/TKv750fAk9HXutCuZ8pyZr6eWrpCRESAinUZiYhIfhQQREQEUEAQEZGI\nAoKIiAAKCCIiElFAEBERQAFBREQi/x8fBwedx1UbFAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x108763fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(poly_svc, axis=[-1.5, 2.5, -1, 1.5])\n",
    "plt.scatter(X[y == 0, 0], X[y == 0, 1])\n",
    "plt.scatter(X[y == 1, 0], X[y == 1, 1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 多项式核函数的SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.svm import SVC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def PolynomialKernelSVC(degree, C = 1.0):\n",
    "    return Pipeline(\n",
    "        [\n",
    "            (\"std_scaler\", StandardScaler()),\n",
    "            (\"kernelSVC\", SVC(kernel=\"poly\", degree=degree, C=C))\n",
    "        ]\n",
    "    ) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "poly_kernel_svc = PolynomialKernelSVC(degree=100)\n",
    "poly_kernel_svc.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_decision_boundary(poly_kernel_svc, axis=[-1.5, 2.5, -1, 1.5])\n",
    "plt.scatter(X[y == 0, 0], X[y == 0, 1])\n",
    "plt.scatter(X[y == 1, 0], X[y == 1, 1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
